var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
});
var r = t("CarConstant"),
s = t("GameConstant"),
l = cc._decorator,
c = l.ccclass,
d = l.property,
h = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.spine_left = null,
        e.spine_right = null,
        e.ani_doorlib = null,
        e._carTag = 0,
        e.aniDoorClips = {
            open: "car_door_lib_open",
            close: "car_door_lib_close"
        },
        e._parent = null,
        e
    }
    return n(e, t),
    e.prototype.onLoad = function() {
        this.ani_doorlib.getClips()
    },
    e.prototype.init = function(t, e, o) {
        var i = {
            rolePos: cc.v3(20, 88, 0),
            roleRotation: 0
        };
        o && (i = r.GetCarBodyData(o)),
        this._parent = t,
        this.node.active = !1,
        this._carTag = e,
        this.spine_left.node.active = e == s.Physics_Car_Tag.Left,
        this.spine_right.node.active = e == s.Physics_Car_Tag.Right,
        this.node.position = e == s.Physics_Car_Tag.Left ? i.rolePos: cc.v3( - i.rolePos.x, i.rolePos.y, i.rolePos.z),
        this.node.angle = e == s.Physics_Car_Tag.Left ? i.roleRotation: -i.roleRotation,
        this.node.scaleX = e == s.Physics_Car_Tag.Left ? this.node.scaleX: -this.node.scaleX
    },
    e.prototype.updateView = function(t, e) {
        var o = {
            rolePos: cc.v3(20, 88, 0),
            roleRotation: 0
        };
        e && (o = r.GetCarBodyData(e)),
        this.node.active = !1,
        this.node.position = o.rolePos,
        this.node.angle = o.roleRotation,
        this.node.scaleX = t ? this.node.scaleX: -this.node.scaleX
    },
    e.prototype.playAniIn = function() {
        var t = this;
        switch (this.node.active = !0, this.ani_doorlib.play(this.aniDoorClips.open), this._carTag) {
            case s.Physics_Car_Tag.Left:
                this.spine_left.setAnimation(0, "chuchang", !1);
            break;
            case s.Physics_Car_Tag.Right:
                this.spine_right.setAnimation(0, "chuchang", !1);
        }
        this.node.stopAllActions(),
        cc.tween(this.node).delay(2).call(function() {
            t.playAniNormal()
        }).start()
    },
    e.prototype.playAniNormal = function() {
        switch (this.node.stopAllActions(), this.node.active = !0, this._carTag) {
            case s.Physics_Car_Tag.Left:
                this.spine_left.setAnimation(0, "changtai_huang", !0);
            break;
            case s.Physics_Car_Tag.Right:
                this.spine_right.setAnimation(0, "changtai_huang", !0);
        }
    },
    e.prototype.playAniOut = function() {
        var t = this;
        switch (this.node.stopAllActions(), this._carTag) {
            case s.Physics_Car_Tag.Left:
                this.spine_left.setAnimation(0, "kaishi", !1);
            break;
            case s.Physics_Car_Tag.Right:
                this.spine_right.setAnimation(0, "kaishi", !1);
        }
        cc.tween(this.node).delay(1).call(function() {
            t.ani_doorlib.play(t.aniDoorClips.close)
        }).start()
    },
    e.prototype.playAniWin = function() {
        var t = this;
        this.node.stopAllActions(),
        cc.tween(this.node).delay(1).call(function() {
            switch (t.ani_doorlib.play(t.aniDoorClips.open), t._carTag) {
                case s.Physics_Car_Tag.Left:
                    t.spine_left.setAnimation(0, "chuchang", !1);
                break;
                case s.Physics_Car_Tag.Right:
                    t.spine_right.setAnimation(0, "chuchang", !1);
            }
        }).start()
    },
    a([d(sp.Skeleton)], e.prototype, "spine_left", void 0),
    a([d(sp.Skeleton)], e.prototype, "spine_right", void 0),
    a([d(cc.Animation)], e.prototype, "ani_doorlib", void 0),
    a([c], e)
} (cc.Component);
o.default = h